import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

const routes = [
  { path: '/home', component: () => import('@/views/HomeView.vue') },
  { path: '/', redirect: '/search' },
  // 查询参数方式传递参数
  // { path: '/search', component: SearchView },
  // 动态路由
  { name: 'search', path: '/search/:key?', component: () => import('@/views/SearchView.vue') },
  { path: '/:pathMatch(.*)*', name: 'NotFound', component: () => import('@/views/NotFound.vue') },
  { path: '/my', name: 'my', component: () => import('@/views/my.vue') },
]

const router = createRouter({
  // history: createWebHashHistory(),
  history: createWebHistory(),
  routes,
})

export default router
